﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TimeToGo.Formatters;
using System.ComponentModel;

namespace TimeToGo.Formatters
{
    internal class DurationFormatterProxy : IDurationFormatter, INotifyPropertyChanged
    {
        private DurationFormatterBase _formatter;
        
        public DurationFormatterProxy(DurationFormatterBase formatter)
        {
            _formatter = formatter;

        }

        public event PropertyChangedEventHandler PropertyChanged;
        private bool _selected;
        public bool Selected
        {
            get { return _selected; }
            set
            {
                if (_selected != value)
                {
                    _selected = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("Selected"));
                }
            }
        }

        protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, e);
        }

        public string Name
        {
            get { return _formatter.Name; }
        }

        public string GetDuration(TimeSpan duration)
        {
            return _formatter.GetDuration(duration);
        }
    }
}
